home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 2002 January / PC Answers January 2002.7z / PC Answers January 2002.bin / graphics / freepixl / _SETUP.1 / Cplaplet.pxl < prev    next >
Text File  |  2000-04-01  |  5KB  |  200 lines

  1. {    Filename    :     CPLapplets.pxl
  2.      Purpose    :    Windows shell and applets
  3.     Date        :    20 aug 98
  4.     Author    :        S.Dibbs, VYSOR Integration Inc
  5. History:
  6.  
  7.     Version    :  1.0    RELEASE
  8.     Update    :  
  9.     Date    :  
  10.  
  11. --------------------------------------------------------------------------}
  12. Initialize: {only one instance allowed}
  13.     UseCoordinates(PIXEL)
  14.     Title$ = "PiXCL 4.4 and the Control Panel Applets"                                  
  15.     WinExist(Title$,Res)
  16.     If Res = 0 Then Goto One_Instance
  17.     Beep
  18.     WinSetActive(Title$,Res)
  19.     WinShow(Title$,RESTORE,Res)
  20.     End
  21. One_Instance:
  22.     WAVPlaySound("cplaplets.wav",ASYNC,FILENAME,Res)
  23.  
  24.     UseCaption(Title$) {change the title}
  25.     WinLocate(Title$,472,188,970,594,Res)                
  26.     UseBackground(TRANSPARENT,0,128,128)     
  27.     WinShow(Title$,NOTOPMOST,Res) 
  28.     DrawBackGround
  29.     DirGet(SourceDir$) {used later for library function calls}
  30.     DirGetWindows(WinDir$)
  31.     DirGetSystem(WinSys$)
  32.     WinVersion(Major,Minor,Build,Pack$)
  33. {
  34.     DrawNumber(10,30, Major)
  35.     DrawNumber(60,30, Minor)
  36.     DrawNumber(100,30, Build)
  37.     DrawText(10,50,Pack$)
  38. }
  39.     { locate rundll32.exe }
  40.     RunDLL$ = WinDir$ + "\rundll32.exe"
  41.     FileExist(RunDLL$,Res)
  42.     If  Res = 0
  43.         RunDLLDir$ = WinSys$
  44.     Else    
  45.         RunDLLDir$ = WinDir$
  46.     Endif
  47.  
  48.     InfoMenu(REMOVE)
  49.     WaitInput(100)
  50.  
  51.     SetMenu("&File",IGNORE,
  52.         "&New",CreatingFile,
  53.         "&Test Applets",OpeningFile,
  54.         "&Format Floppy",FormatFloppy,
  55.         SEPARATOR,
  56.         "E&xit!",Terminate,
  57.         ENDPOPUP,
  58.         "&View",IGNORE,
  59.         "&ToolBar",ViewToolBar,
  60.         "&StatusBar",ViewStatusBar,
  61.         ENDPOPUP,
  62.         "&Information",IGNORE,
  63.         "&Concept",Concept,
  64.         "&Help",ShowAppHelp,
  65.         SEPARATOR,
  66.         "&About",About,
  67.         ENDPOPUP)
  68.  
  69.     GoSub MakeToolbar
  70.     ChangeMenuItem("&ToolBar",CHECK,TBRes)
  71.         
  72.     StatusWindow(ENABLE,BOTTOM,2,500,-1,0,0)
  73.     DrawStatusWinText(0,"Ready")
  74.     ChangeMenuItem("&StatusBar",CHECK,SBRes)
  75.  
  76. Wait_for_Input:
  77.     WaitInput()
  78.  
  79. Terminate:
  80.     End
  81.  
  82.  
  83. Concept:
  84.     MessageBox(OK,1,INFORMATION,
  85. "This sample file opens the various control panel applet files
  86. located in the Windows system directory, and demonstrates the 
  87. functions available within the applet.",
  88.     Title$,Res)
  89.  
  90.     Goto Wait_for_Input
  91.  
  92. ShowAppHelp:
  93.     {An application Help file usually has the same name as the application.}
  94.     Winhelp("cplaplet.hlp",CONTENTS,"")
  95.  
  96.     Goto Wait_for_Input
  97.  
  98. About:
  99.     AboutUser(Title$,
  100.       "Identifying the Control Panel Applets.",
  101.     "Selects a Control Panel applet and check the contents by running a Windows shell command.")
  102.  
  103.     Goto Wait_for_Input
  104.  
  105. ViewToolBar:
  106.     GetMenuStatus("&ToolBar",CHECKED,Res)
  107.     If Res = 0
  108.         GoSub MakeToolbar
  109.         ChangeMenuItem("&ToolBar",CHECK,Res)
  110.     Else
  111.         Toolbar()
  112.         ChangeMenuItem("&ToolBar",UNCHECK,Res)
  113.     Endif
  114.     Goto Wait_for_Input
  115.  
  116. ViewStatusBar:
  117.     GetMenuStatus("&StatusBar",CHECKED, Res)
  118.     If Res = 0
  119.         StatusWindow(ENABLE,BOTTOM,2,500,-1,0,0)
  120.         DrawStatusWinText(0,"Ready")
  121.         ChangeMenuItem("&StatusBar",CHECK,Res)
  122.     Else
  123.         StatusWindow(DISABLE,BOTTOM,2,500,-1,0,0)
  124.        ChangeMenuItem("&StatusBar",UNCHECK,Res)
  125.     Endif
  126.     Goto Wait_for_Input
  127.  
  128. CreatingFile:
  129.     {TODO: add file handling here}
  130.     MessageBox(OK,1,EXCLAMATION,"Look at the source code, at label 'CreatingFile:'","No function coded for this button",Res)
  131.     Goto Wait_for_Input
  132.  
  133. OpeningFile:
  134.     WaitInput(1)
  135.     WAVPlaySound("opencpl.wav",ASYNC,FILENAME,Res)
  136.     Filter$ = "Control Panel Applets (*.cpl),*.cpl"
  137.     InitFile$ = "*.cpl"
  138.     Label$ = "Select a Control Panel Applet file to examine."
  139.     FileGet(Filter$,InitFile$,WinSys$,Label$,CHANGEDIR,CPLfile$)
  140.     If CPLfile$ = "" Then Goto Wait_for_Input
  141.     
  142.     {Loop through the CPL file arguments and see what these applets do}
  143.     Ansi("0",Index)
  144.     Cmd$ = RunDLLDir$ + "\rundll32.exe shell32.dll,Control_RunDLL "
  145.     Cmd$ = Cmd$ + CPLfile$
  146.     Cmd$ = Cmd$ + ",@"
  147.     Chr(Index,App$)
  148.     CmdLine$ = Cmd$ + App$
  149.     {CmdLine$ = CmdLine$ + ",1" } {add extra to select property page}
  150.     RightOf(CmdLine$,50,Rpt$)
  151.     DrawStatusWinText(0,Rpt$)
  152.     WaitInput(100)
  153.     Run(CmdLine$)
  154.  
  155. Loop:
  156.     MessageBox(YESNO,1,QUESTION,
  157.         "Get next applet ? If no new applet dialog appears, click No",CPLfile$,Res)
  158.     If Res = 2 Then DrawStatusWinText(0,"Ready") Goto Wait_for_Input
  159.     WaitInput(100)
  160.     Index++
  161.     Chr(Index,App$)
  162.     CmdLine$ = Cmd$ + App$
  163.     {CmdLine$ = CmdLine$ + ",1" } {add extra to select property page}
  164.     RightOf(CmdLine$,50,Rpt$)
  165.     DrawStatusWinText(0,Rpt$)
  166.     WaitInput(100)
  167.     Run(CmdLine$)
  168.     Goto Loop
  169.  
  170. FormatFloppy:
  171.     WaitInput(1)
  172.     Cmd$ = RunDLLDir$ + "\rundll32.exe shell32.dll,SHFormatDrive"
  173.     Run(Cmd$) 
  174.     {This displays a modeless dialog that accepts input, and PiXCL will go back to the idle
  175.         loop unless code, such as below, is used.}
  176. {
  177.     FormatWin$ = "Format - 3╜ Floppy (A:)"
  178.     WinExist(FormatWin$,Res)
  179.     If Res = 1
  180.         While Res = 1
  181.             WinExist(FormatWin$,Res)
  182.         EndWhile
  183.     Endif
  184. }
  185.     Goto Wait_for_Input
  186.  
  187.  
  188. {--- Style Suggestion: place all subroutines at the end of the script.}
  189.  
  190. MakeToolbar: {subroutine}
  191.     Toolbar(RAISED, PXL_SMALL,
  192.         NULL, NULL, SEPARATOR, "", Wait_for_Input,
  193.         PXL_NEW, ENABLED, STD, "FileNew", CreatingFile,
  194.         PXL_OPEN, ENABLED, STD, "Test Control Panel Applets", OpeningFile,
  195.         PXL_SAVE, ENABLED, STD, "Format Floppy", FormatFloppy,
  196.         NULL, NULL, SEPARATOR, "", Wait_for_Input,
  197.         HELPINFO, ENABLED, STD,"Show Help",ShowAppHelp)
  198.  
  199.     Return
  200.